﻿@using CleanArchitecture.Blazor.Application.Features.Contacts.Queries.Pagination
@inject IStringLocalizer<Contacts> L

<MudExpansionPanel @bind-Expanded="_advancedSearchExpanded"
                   Style="border-radius: var(--mud-default-borderradius) !important;"
                   Class="mud-elevation-25 pa-2 mb-3" Text="@ConstantString.AdvancedSearch">
    <MudGrid>
        <MudItem xs="12" sm="6" md="4">
            @*TODO: define advanced search query fields, for example:*@
            @*<MudTextField @bind-Value="TRequest.Name" 
                          Placeholder="@L["Search for name"]"
                          Clearable="true"
                          TextChanged="TextChanged">
            </MudTextField>*@
        </MudItem>
     </MudGrid>
</MudExpansionPanel>

@code {
    [EditorRequired][Parameter] public ContactsWithPaginationQuery TRequest { get; set; } = null!;
    [EditorRequired][Parameter] public EventCallback<string> OnConditionChanged { get; set; }
    private bool _advancedSearchExpanded;
    private async Task TextChanged(string str)
    {
        if (_advancedSearchExpanded)
        {
          await OnConditionChanged.InvokeAsync(str);
        }
    }
}